<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>ispace</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script type="text/javascript"  src="/front/dist/ispace.core.main.js" ></script>
    <script>
        var server = window.location.host
        function getToken() {
            $.ajax({
                url: '/api/GetToken',
                method: 'POST',
                data:{name:"alei",password:"1qaz@WSX"},
                success: function (response) {
                    console.log('Token:', response);
                }, 
                error: function (xhr, status, error) {
                    console.error('Error:', error);
                }
            });
        }

        function validateToken() {
            var token = prompt('Enter the token:');
            $.ajax({
                url: '/api/VerifyToken',
                method: 'GET',
                data: { token: token },
                success: function (response) {
                    console.log('Token is valid:', response);
                },
                error: function (xhr, status, error) {
                    console.error('Error:', error);
                }
            });
        }
    </script>
</head>

<body>
    <button onclick="ispace.auth.getToken('alei','1qaz@WSX').subscribe(s=>{console.log(s)})">Get Token</button>
    <button onclick="ispace.auth.validateToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTkyMTAxODEsIm5hbWUiOiJhbGVpIn0.0tFe1RBXvtvLfjI8qsJgeMQt707BWua12OYVHHR5mSg').subscribe(s=>{console.log(s)})">Validate Token</button>
</body>

</html>